package com.nightpiter.model.objects;

import java.util.ArrayList;

/**
 * @author Cthulhu
 * @author Ilya Shurigyn (honorik@gmail.com)
 * @author Eldar Abusalimov (eldar.abusalimov@gmail.com)
 */

public class Hub {
	private ArrayList<Station> stations = new ArrayList<Station>();

	private ArrayList<HubComponent> components = new ArrayList<HubComponent>();

	public Hub(ArrayList<Transfer> transfers) {
		for (Transfer transfer : transfers) {
			this.addTransfer(transfer);
		}

	}

	private void addTransfer(Transfer transfer) {
		Station fromStation = transfer.fromStation;
		Station toStation = transfer.toStation;
		if (!stations.contains(fromStation)) {
			stations.add(fromStation);
		}
		if (!stations.contains(toStation)) {
			stations.add(toStation);
		}
		transfer.setHub(this);
	}

	public ArrayList<Station> getStations() {
		return stations;
	}

	public ArrayList<HubComponent> getComponents() {
		return components;
	}

	public void addComponentOfHub(HubComponent component) {
		components.add(component);
	}

}
